package com.warm.base.jdk.base;

/**
 * @Date: 2020/4/10 15:12
 * @Author: LChuang
 * @Description:
 */
public class ExternalClass {
    /**
     * 实例成员
     */
    private int a1 = 1;

    /**
     * 类成员
     */
    private static int b1 = 3;

    public static int b2 = 4;


    public void externalPublicPrint(){
        System.out.println("External Public Method");
    }

    private void externalPrivatePrint(){
        System.out.println("External Private Method");
    }

    public static void externalStaticPrint(){
        System.out.println("External Static Method");
    }

    public void innerClassPrint(){
        System.out.println("External --> InnerClass");
        InnerClass innerClass = new InnerClass();
        System.out.println("InnerClass Private Variable: " + innerClass.d1);
        System.out.println("InnerClass Public Variable: " + innerClass.d2);
        innerClass.innerClassPrivatePrint();
        innerClass.innerClassPublicPrint();
        System.out.println("InnerClass Static -- not allow");

    }

    public void innerStaticClassPrint(){
        System.out.println("External --> InnerStaticClass");
        System.out.println("InnerStaticClass Static Private Variable: "+ InnerStaticClass.c1);
        System.out.println("InnerStaticClass Static Public Variable: "+ InnerStaticClass.c2);
        /*System.out.println("InnerStaticClass Private Variable: "+ InnerStaticClass.c3);
        System.out.println("InnerStaticClass Public Variable: "+ InnerStaticClass.c4);*/
        System.out.println("InnerStaticClass Private Variable -- not allow");
        System.out.println("InnerStaticClass Public Variable -- not allow ");
        InnerStaticClass.innerStaticPrint();
        InnerStaticClass innerStaticClass = new InnerStaticClass();
        System.out.println("InnerStaticClass Private Variable : " + innerStaticClass.c4);
        System.out.println("InnerStaticClass Public Variable : " + innerStaticClass.c3);
    }

    class InnerClass{

        private int d1 = 7;

        public int d2 = 8;

        public void innerClassPublicPrint(){
            System.out.println("InnerClass Public Method");
        }

        private void innerClassPrivatePrint(){
            System.out.println("InnerClass Private Method");
        }
    }

    static class InnerStaticClass{

        private static int c1 = 5;

        public static int c2 = 6;

        public int c3 = 7;

        private int c4 = 8;

        /**
         * 类方法
         */
        public static void innerStaticPrint(){
            System.out.println("Static InnerClass Static Method");
            // 静态内部类不能访问外部类 实例成员, 可以访问外部 类成员
            //System.out.println(a);
            System.out.println("External Static Variable: " + b1);
        }

        /**
         * 实例方法
         */
        public void innerPublicPrint(){
            System.out.println("Static InnerClass Public Method");
            InnerStaticClass inner = new InnerStaticClass();
            inner.innerPublicPrint();
            InnerStaticClass.innerStaticPrint();
        }

        private void innerPrivatePrint(){
            System.out.println("Static InnerClass Public Method");
        }
    }

}
